package com.shop.controller;

import com.shop.pojo.OrderStatus;
import com.shop.service.OrderStatusService;
import com.shop.vo.JSONResponse;
import com.shop.vo.OrderStatusSaveRequest;
import com.shop.vo.OrderStatusUpdateRequest;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



/**
 * 订单状态表;订单的每个状态更改都需要进行记录
10：待付款  20：已付款，待发货  30：已发货，待收货（7天自动确认）  40：交易成功（此时可以评价）50：交易关闭（待付款时，用户取消 或 长时间未付款，系统识别后自动关闭）
退货/退货，此分支流程不做，所以不加入
 *
 * @author yukangkang
 * @email sunlightcs@gmail.com
 * @date 2020-10-30 13:16:29
 */
@RestController
@RequestMapping("order-status")
public class OrderStatusController {

    @Autowired
    private OrderStatusService orderStatusService;



    /**
     * 信息
     */
    @GetMapping("/info/{orderId}")
    @ApiOperation(value = "详情")
    public JSONResponse info(@PathVariable("OrderId") String orderId){
		OrderStatus orderStatus = orderStatusService.getById(orderId);
        return JSONResponse.ok(orderStatus);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation(value = "保存")
    public JSONResponse save(@RequestBody OrderStatusSaveRequest request){
		orderStatusService.save(request);
        return JSONResponse.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    @ApiOperation(value = "修改")
    public JSONResponse update(@RequestBody OrderStatusUpdateRequest request){
		orderStatusService.update(request);
        return JSONResponse.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete/{orderId}")
    @ApiOperation(value = "删除")
    public JSONResponse delete(@PathVariable String orderId){
		orderStatusService.delete(orderId);
        return JSONResponse.ok();
    }

}
